<?php
namespace library\widgets;

use idea\mvc\Widget;
use idea\saf\Conf;

/**
 * BreadCrumbs class file
 * 面包屑
 * @author 宋欢 <iphper@yeah.net>
 * @version $Id: BreadCrumbs.php 1 2013-04-20 17:11:06Z huan.song $
 * @package library.widgets
 * @since 1.0
 */
class BreadCrumbs extends Widget
{
	/**
	 * 执行Widget类，输出内容
	 * @return void
	 */
	public function run()
	{	
		$urls = Conf::getAppConf('urls');
		
		$html = $this->getHtml()->openTag('div', array('class' => 'current'));
		foreach ($this->_tplVars as $key => $urlName) {
			if (isset($urls[$urlName]['href']) && count($this->_tplVars) > 1) {
				$html .= $this->getHtml()->a($urls[$urlName]['label'], $urls[$urlName]['href']) . ' &gt; ';
			}
			else {
				$html .= $urls[$urlName]['label'] . ' &gt; ';
			}
			
			unset($this->_tplVars[$key]);
		}
		$html = substr($html, 0, -6) . $this->getHtml()->closeTag('div');
		
		echo $html;
	}
}
